package com.cac.demo.newCode.sorting.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cac.demo.newCode.sorting.mapper.MsGkLogMapper;
import com.cac.demo.newCode.sorting.service.IMsGkLogService;
import com.cac.demo.newCode.sorting.entity.MsGkLog;
import com.cac.demo.util.adapter.ResponseMsg;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 立体库调用信息表 服务实现类
 * </p>
 *
 * @author xz
 * @since 2024-08-27
 */
@Service
public class MsGkLogServiceImpl extends ServiceImpl<MsGkLogMapper, MsGkLog> implements IMsGkLogService {

    @Override
    public ResponseMsg<Object> getStoreDay() {
        LocalDate date = LocalDate.now();
        LocalDateTime startOfDay = date.atStartOfDay();
        LocalDateTime endOfDay = date.atTime(LocalTime.MAX);

        LambdaQueryWrapper<MsGkLog> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.between(MsGkLog::getOrderStartTime, startOfDay, endOfDay);
        queryWrapper.eq(MsGkLog::getTaskType, "1");
        List<MsGkLog> msGkLogs = this.baseMapper.selectList(queryWrapper);
        return new ResponseMsg<>().setResponseBody(msGkLogs.size());
    }

    @Override
    public ResponseMsg<Object> getOutboundDay() {
        LocalDate date = LocalDate.now();
        LocalDateTime startOfDay = date.atStartOfDay();
        LocalDateTime endOfDay = date.atTime(LocalTime.MAX);

        LambdaQueryWrapper<MsGkLog> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.between(MsGkLog::getOrderStartTime, startOfDay, endOfDay);
        queryWrapper.eq(MsGkLog::getTaskType, "2");
        List<MsGkLog> msGkLogs = this.baseMapper.selectList(queryWrapper);
        return new ResponseMsg<>().setResponseBody(msGkLogs.size());
    }
}
